package com.cy.lib.util;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * Created by CY on 2015/8/30.
 */
public class JsonUtils {

    public static Map<String, Object> jsonToMap(String jsonObjStr) {

        try {
            Map<String, Object> map = new HashMap<>();
            JSONObject jobj = new JSONObject(jsonObjStr);
            Iterator<String> iteratorKeys = jobj.keys();
            while (iteratorKeys.hasNext()) {
                String key = iteratorKeys.next();
                Object value = jobj.get(key);
                map.put(key, value);
            }
            return map;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;

    }
}
